<template>
  <div>
    <div class="msgDiv">
      <!-- <div class="nameDiv">{{ worker.library.title }}</div> -->
      <ContainerTitle text="个人基本信息" class="title"></ContainerTitle>
      <!-- <div class="titleDiv">
        <div style="margin-bottom: 5px">个人基本信息</div>
      </div> -->
      <div class="tableDiv">
        <div class="rowDiv">
          <div class="keyDiv">姓名</div>
          <div class="valueDiv">{{ worker.library.name }}</div>
          <div class="keyDiv">性别</div>
          <div class="valueDiv">{{ worker.library.genderName }}</div>
        </div>
        <div class="rowDiv">
          <div class="keyDiv">年龄</div>
          <div class="valueDiv">{{ worker.library.age }}</div>
          <div class="keyDiv">学历</div>
          <div class="valueDiv">{{ worker.library.educationName }}</div>
        </div>
        <div class="rowDiv">
          <!-- <div class="keyDiv">身份证号</div>
          <div class="valueDiv">{{ worker.library.idCard }}</div> -->
            <div class="keyDiv">职业技能</div>
          <div class="valueDiv">{{ worker.library.skill }}</div>
          <div class="keyDiv">联系电话</div>
          <div class="valueDiv">{{ worker.library.contact }}</div>
        </div>
        <!-- <div class="rowDiv">
          <div class="keyDiv">现居住地址</div>
          <div class="valueDiv">{{ worker.library.address }}</div>
          <div class="keyDiv">期望薪资</div>
          <div class="valueDiv">{{ worker.library.expectSalary }}</div>
        </div> -->
        <!-- <div class="rowDiv" style="border-bottom: 0">
          <div class="keyDiv">期望行业</div>
          <div class="valueDiv">{{worker.library.expectTrade}}</div>
          <div class="keyDiv">需求岗位</div>
          <div class="valueDiv" style="flex: 1">
            {{ worker.library.post }}
          </div>
        </div> -->
      </div>
      <div class="titleDiv">
        <div style="margin-bottom: 5px">工作经验</div>
      </div>
      <div class="tableDiv">
        <div v-for="(experience, index) in worker.experience" :key="index">
          <div class="rowDiv">
            <div class="keyDiv">公司名称</div>
            <div class="valueDiv">{{ experience.companyName }}</div>
            <div class="keyDiv">工作时间</div>
            <div class="valueDiv">
              {{ experience.beginDate + " - " + experience.endDate }}
            </div>
          </div>
          <div
            class="rowDiv">
            <div class="keyDiv">部门</div>
            <div class="valueDiv">{{ experience.dept }}</div>
            <div class="keyDiv">职位</div>
            <div class="valueDiv">{{ experience.post }}</div>
          </div>
          <div
            class="rowDiv"
            :style="
              index == worker.experience.length - 1
                ? 'border-bottom: 0'
                : ''
            "
          >
            <div class="keyDiv">工作内容</div>
            <div class="fullDiv">{{ experience.workContent }}</div>
          </div>
        </div>
      </div>
      <div class="titleDiv">
        <div style="margin-bottom: 5px">申请状态</div>
      </div>
      <div class="tableDiv">
        <div class="rowDiv" style="border-bottom: 0">
          <div class="keyDiv">申请时间</div>
          <div class="valueDiv">{{ worker.sendTime }}</div>
          <div class="keyDiv">状态</div>
          <div
            class="valueDiv"
            :style="'color: ' + formantStatus(worker.status).color"
          >
            {{ formantStatus(worker.status).label }}
          </div>
        </div>
      </div>
      <div class="btn-bottom">
        <Buttons :buttons="buttons" @goBack="goBack" @confirmWorkerReject="confirmWorkerReject" @confirmWorkerPass="confirmWorkerPass"></Buttons>
        <!-- <div class="cancelBtn" @click="goBack()">返回</div>
        <div
          class="btnsDiv"
          v-if="worker.status == 1 || worker.status == 4"
        >
          <div
            @click="confirmWorkerReject()"
            style="background-color: #d00000"
          >
            拒绝
          </div>
          <div @click="confirmWorkerPass()">录用</div>
        </div> -->
      </div>
    </div>
  </div>
</template>

<script>
// import Tinymce from "@/components/tinymce";

import { getWorker, Pass, Reject } from "@/common/api/company.js";

export default {
  name: "companyRecruitWorkerList",
  // components: { Tinymce },
  computed:{
    buttons(){
      let btns = [
        {text:"返回",type:"normal",size:"l",method:"goBack"}
      ]
      if(this.worker.status == 1 || this.worker.status == 4){
        btns.push({text:"拒绝",type:'error' ,size:"l",method:"confirmWorkerReject"})
        btns.push({text:"录用",type:'success' ,size:"l",method:"confirmWorkerPass"})
      }
      return btns;
    }
  },
  data() {
    return {
      crumbs: [
        {
          label: "企业空间",
          value: "company",
        },
        {
          label: "人才服务",
          value: "companyMyApply",
        },
        {
          label: "我的招聘",
          value: "companyMyRecruit",
        },
        {
          label: "应聘人员",
          value: "companyRecruitWorkerList",
        },
        {
          label: "应聘人员详细资料",
          value: "companyRecruitWorkerDetail",
          choose: true,
        },
      ],
      worker: {},
      statusList: [
        {
          value: 1,
          label: "待查看",
        },
        {
          value: 2,
          label: "已通过",
          color: "#10a217",
        },
        {
          value: 3,
          label: "未通过",
          color: "#d00000",
        },
        {
          value: 4,
          label: "已查看",
          color: "#10a217",
        },
      ],
    };
  },
  methods: {
    /**
     * 返回上一页
     */
    goBack: function () {
      this.$router.back();
    },
    /**
     * 格式化显示状态
     * @param status 要格式化的状态
     */
    formantStatus(status) {
      let ns = this;
      if (status == null || status == undefined) {
        return { label: "" };
      }
      for (let i = 0; i < ns.statusList.length; i++) {
        if (status == ns.statusList[i].value) {
          return ns.statusList[i];
        }
      }
      return { label: "" };
    },
    /**
     * 获取应聘人员详情
     * @return {Promise<void>}
     */
    async getWorker() {
      let ns = this;
      let { code, msg, data } = await getWorker(ns.$route.query.id);
      ns.worker = data;
    },
    /**
     * 确认录用应聘人员
     */
    confirmWorkerPass() {
      let ns = this;
      ns.$confirm("确认录用应聘人员？").then((_) => {
        ns.workerPass();
      });
    },
    /**
     * 录用应聘人员
     * @return {Promise<void>}
     */
    async Pass() {
      let ns = this;
      let { code, msg } = await Pass({ id: ns.worker.id });
      if (code == 200) {
        ns.$message.success("操作成功");
        ns.getWorker();
      } else {
        ns.$message.error(msg);
      }
    },
    /**
     * 确认拒绝应聘人员
     */
    confirmWorkerReject() {
      let ns = this;
      ns.$confirm("确认拒绝应聘人员？").then((_) => {
        ns.workerReject();
      });
    },
    /**
     * 拒绝应聘人员
     * @return {Promise<void>}
     */
    async workerReject() {
      let ns = this;
      let { code, msg } = await Reject({ id: ns.worker.id });
      if (code == 200) {
        ns.$message.success("操作成功");
        ns.getWorker();
      } else {
        ns.$message.error(msg);
      }
    },
  },
  mounted() {
    let ns = this;
    ns.getWorker();
  },
};
</script>

<style scoped>
.breadcrumb {
  margin: 20px 0;
}

.roomDiv {
  display: flex;
  justify-content: center;
}

.roomDiv .leftDiv {
  width: 200px;
  text-align: left;
}

.roomDiv .rightDiv {
  width: 800px;
  margin-left: 30px;
}

.requirementPost {
  font-size: 24px;
  font-weight: bold;
  text-align: left;
  margin: 20px 0;
}

.titleDiv {
  border-bottom: 2px solid #045db9;
  text-align: left;
  padding: 5px 0;
  font-size: 20px;
  font-weight: bold;
  color: #045db9;
  margin: 20px 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.msgDiv {
  margin-bottom: 50px;
}

.msgDiv .nameDiv {
  text-align: left;
  font-size: 25px;
  font-weight: bold;
}

.btnsDiv {
  display: flex;
}
.btnsDiv div {
  padding: 10px 40px;
  color: #ffffff;
  background-color: #045db9;
  margin-right: 30px;
  font-size: 15px;
  border-radius: 5px;
}

.btnsDiv div:hover {
  cursor: pointer;
}

::v-deep .el-table tbody tr:hover > td {
  background-color: #ffffff !important;
}

::v-deep .el-table td,
.el-table th.is-leaf,
.el-table--border,
.el-table--group {
  border-color: #eeeeee;
}

::v-deep .is-leaf {
  font-weight: normal;
}

::v-deep .el-table td,
.el-table th {
  padding: 10px 0;
}

.rowBtn {
  text-decoration: underline;
  color: #045db9;
}

.rowBtn:hover {
  cursor: pointer;
}

.tableDiv {
  font-size: 13px;
  border: 1px solid #eeeeee;
  color: #666666;
}

.tableDiv .rowDiv {
  display: flex;
  /* justify-content: space-between;   */
  border-bottom: 1px solid #eeeeee;
}

.tableDiv .rowDiv .keyDiv {
  padding: 10px;
  background-color: #f4f4f4;
  width: 85px;
  text-align: left;
  flex-shrink: 0;
}

.tableDiv .rowDiv .valueDiv {
  padding: 10px;
  width: 302px;
  text-align: left;
  word-wrap: break-word;
}

.tableDiv .rowDiv .fullDiv {
  padding: 10px;
  text-align: left;
  word-break: break-all;
}

#pageDiv {
  display: flex;
  justify-content: center;
}

#pageDiv #policyPagination {
  margin-bottom: 30px;
  width: 800px;
  text-align: right;
}

#selectTypeDiv {
  width: 800px;
  display: flex;
  border-bottom: 3px solid #d00000;
  padding: 0 20px;
}

#selectTypeDiv div {
  padding: 5px 20px;
  font-weight: bold;
}

#selectTypeDiv .selectType {
  background-color: #d00000;
  color: #ffffff;
}

#selectTypeDiv .btn:hover {
  background-color: #d00000;
  color: #ffffff;
  cursor: pointer;
  transition: all 0.2s ease 0s;
}

.layout {
  min-height: 100vh;
  position: relative;
  padding-bottom: 150px;
  box-sizing: border-box;
}
.btn-bottom {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 40px 0 150px;
}
.btn-bottom .cancelBtn {
  display: inline-block;
  font-size: 14px;
  background-color: #f1f2f4;
  color: #045db9;
  padding: 10px 46px;
  text-align: center;
  border-radius: 5px;
  margin-right: 30px;
}
.btn-bottom .cancelBtn:hover {
  /* border: 1px solid #eeeeee; */
  cursor: pointer;
  box-shadow: 0px 0px 5px #eeeeee;
}

.footer {
  position: absolute;
  bottom: 0;
  width: 100%;
}
</style>
